]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/keyboard: Simplify MRU list updates
authorMaksim Mazko <undeparg@gmail.com>
Fri, 6 Mar 2026 13:20:10 +0000 (16:20 +0300)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 14 Mar 2026 10:57:01 +0000 (11:57 +0100)
Rewrite the update logic to a more direct form, improving readability by
removing the manual iteration and list manipulation.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4101>

js/ui/status/keyboard.js

index 58b48133637134f49e46746ea08134c9842a9cf4..b1527e3c441bda1570b57c3392602dce4beed4eb 100644 (file)
@@ -490,13 +490,11 @@ export class InputSourceManager extends Signals.EventEmitter {
 
         this.emit('current-source-changed', oldSource);
 
-        for (let i = 1; i < this._mruSources.length; ++i) {
-            if (this._mruSources[i] === newSource) {
-                const currentSource = this._mruSources.splice(i, 1);
-                this._mruSources = currentSource.concat(this._mruSources);
-                break;
-            }
-        }
+        this._mruSources = [
+            newSource,
+            ...this._mruSources.filter(s => s !== newSource),
+        ];
+
         this._changePerWindowSource();
     }